/**
 *
 * Copyright (C) 2008  Igor Vdovichenko
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Though a sincere effort has been made to deliver a professional,
 * quality product,the library itself is distributed WITHOUT ANY WARRANTY;
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 */
package com.vin.scriptutils.utils.ssh;
import java.io.IOException;

/**
 *
 * @author igor
 */
public abstract class SshConnection extends ConnectionInfo{

    private int port = 22;
    private int connectTimeout = 0;

    public SshConnection() {
       super();
    }

    public SshConnection(final ConnectionInfo ci) {
       super(ci);
    }

    /**
     * Get SSH port
     * @return
     */
    public int getPort() {
        return port;
    }

    /**
     * Set SSH port
     * @param port ssh port
     */
    public void setPort(int port) {
        this.port = port;
    }

    /**
     * getConnectTimeout() 
     * @return
     */
    public int getConnectTimeout() {
        return connectTimeout;
    }

    /**
     * setConnectTimeout
     * @param connectTimeout
     */
    public void setConnectTimeout(int connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    @Override
    public SshConnection HostAddress(String hostAddress) {
        setHostAddress(hostAddress);
        return this;
    }

    public SshConnection Port(int port) {
        setPort(port);
        return this;
    }

    public SshConnection ConnectTimeout(int connectTimeout) {
        setConnectTimeout(connectTimeout);
        return this;
    }

    @Override
    public SshConnection Username(String username) {
        setUsername(username);
        return this;
    }

    @Override
    public SshConnection Password(String password) {
        setPassword(password);
        return this;
    }

    abstract public boolean authenticate() throws IOException;
}
